/**
 * 最近更新: 2018-10-19
 * 作者: zuojie
 * 功能: 后端表单验证信息转换
 */

//后端表单验证信息转换
export const conversionFormVerification = (thatMsg, thisMsg) => {
  Object.keys(thatMsg).forEach(function(key) {
    thisMsg[key].status = "error";
    thisMsg[key].message = thatMsg[key];
  });
  return thisMsg;
};

//初始化后端表单验证信息
export const initFormVerification = errorMsg => {
  Object.keys(errorMsg).forEach(function(key) {
    errorMsg[key].status = "";
    errorMsg[key].message = "";
  });
  return errorMsg;
};

export const createObj = (errorMsg,values) => {
  var obj = {};
  Object.keys(errorMsg).forEach(function(key) {
    obj[key] = {
      value: values[key],
      errors: [new Error(errorMsg[key])]
    };
  });
  return obj;
};
